<template>
  <el-table
    :data="tableData"
    stripe
    :border="true"
    row-key="id"
    default-expand-all
  >
    <el-table-column prop="corporationName" label="登录公司" />
    <el-table-column prop="ip" label="登录ip" width="200" />
    <el-table-column prop="userName" label="登录用户" />
    <el-table-column prop="country" label="所在国家" />
    <el-table-column prop="prov" label="所在省份" />
    <el-table-column prop="city" label="所在市" />
    <el-table-column prop="area" label="所在区域" />
    <el-table-column prop="createTime" label="登录时间" />
  </el-table>
  <pageLayout :pageData="page" @pageBnt="pageClick"></pageLayout>
</template>
  <script lang="ts" setup>
import { onMounted, reactive, ref } from "vue";
import { LoginLogOutPut } from "@/model/loginLog/loginLog";
import { getLoginLogMsg } from "@/api/user";
import { basePageModel, pageCofing } from "@/model/public/public";
import pageLayout from "../../components/page.vue";

//初始加载dom
onMounted(() => {
  getAllLoginLogMsg();
});

//table数据
const tableData = ref<LoginLogOutPut[]>([]);

//分页
const page = reactive<basePageModel>({
  currentPage: pageCofing.currentPage,
  pageSize: pageCofing.pageSize,
  total: pageCofing.total,
});

//获取table数据
const getAllLoginLogMsg = () => {
  getLoginLogMsg({
    currentPage: page.currentPage,
    pageSize: page.pageSize,
  }).then(({ data, code, msg, total }) => {
    tableData.value = data;
    page.total = total;
  });
};

//分页点击事件
const pageClick = function (basePageModel: basePageModel) {
  page.currentPage = basePageModel.currentPage;
  page.pageSize = basePageModel.pageSize;
  getAllLoginLogMsg();
};
</script>
  <style scoped>
</style>